home *** CD-ROM | disk | FTP | other *** search
/ Aminet 24 / Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso / Aminet / util / rexx / XpkCEd.lha / XPKCed.ced next >
Text File  |  1997-11-12  |  16KB  |  487 lines

  1. /* XPKCed.ced */
  2. /*************************************************************************
  3. ** $VER: XPKCed.ced 1.1 (16.12.97)                    **
  4. **                                    **
  5. ** Copyright ©1996 Frédéric Delacroix, FreeWare                **
  6. **                                    **
  7. ** This ARexx script handles XPK-crunched files from within Cygnus-Ed    **
  8. ** 3.5 (not tested with other versions of CED). This way you will be    **
  9. ** able to open and save XPK files.                    **
  10. **                                    **
  11. ** This program requires rexxxpk.library and rexxreqtools.library.    **
  12. **    rexxxpk.library is ©1996 Frédéric Delacroix            **
  13. **    rexxreqtools.library is ©1992-1993 Rafael D'Halleweyn        **
  14. ** If the "List packers" option is to be used in the string requester,    **
  15. ** you need the "RequestList" command (or compatible), which is        **
  16. ** copyright ©1995 Adam Dawes.                        **
  17. **                                    **
  18. ** Installation:                            **
  19. **    copy XPKCed.ced to REXX: and be sure RexxMast was launched    **
  20. **    before using this program (this should have been done at    **
  21. **    startup). Copy the rexxxpk.library to LIBS:.            **
  22. **                                    **
  23. **    It's quite useful to bind a key to this program. I personnally    **
  24. **    did bind right amiga ` to XPKCed GUI (defined as a CEd macro).    **
  25. **    If you want, you can replace (with this method) the keyboard    **
  26. **    shortcuts of Ced's menus (Open, Save, Save as, etc.) with calls **
  27. **    to this macro with corresponding arguments. I don't do this    **
  28. **    personnally.                            **
  29. **                                    **
  30. ** Usage (launched from Cygnus-Ed):                    **
  31. **                                    **
  32. **  _ XPKCed GUI                            **
  33. **    presents you with a reqtools requester for you to select what    **
  34. **    to do: OPEN, INCLUDE, SAVE, SAVEAS or SAVEQUIT. A status (as    **
  35. **    produced by XPKCed STATUS) is also shown in the requester.    **
  36. **                                    **
  37. **  _ XPKCed OPEN [Password]                        **
  38. **    will open a (possibly) crunched file. The password will be used    **
  39. **    if the file is crypted. If the file is crypted and no password    **
  40. **    is given a requester will appear.                **
  41. **                                    **
  42. **  _ XPKCed INCLUDE [Password]                        **
  43. **    will include a file into the current one, automatically        **
  44. **    handling XPK compression.                    **
  45. **                                    **
  46. **  _ XPKCed SAVE [Packer[.efficiency] [Password]]            **
  47. **    will save the file with its previous name, crunched with the    **
  48. **    mentionned packer. The password, if given, will be used to    **
  49. **    encrypt the data, provided the packer supports encryption.    **
  50. **                                    **
  51. **  _ XPKCed SAVEAS [Packer[.efficiency] [Password]]            **
  52. **    does the same as SAVE, except that a file requester appears for    **
  53. **    you to select the name of the file to save to.            **
  54. **                                    **
  55. **  _ XPKCed SAVEQUIT [Packer[.efficiency] [Password]]            **
  56. **    same as SAVE, except that Ced will quit after saving the file.    **
  57. **                                    **
  58. **  _ XPKCed STATUS                            **
  59. **    displays a requester displaying XPK information about the last    **
  60. **    XPKCed operation.                        **
  61. **                                    **
  62. ** WARNINGS:                                **
  63. **    1) The filenotes are used to store important data.        **
  64. **    2) If you open a crunched file, it is first decrunched on disk, **
  65. **       so there should be enough room (but it won't cause damage if **
  66. **       you don't since the original file is only overwritten if the **
  67. **       XPK operation succeeds. Remember to save the file again      **
  68. **       even if you didn't modify it, or else it will remain        **
  69. **       in uncompressed form.
  70. **                                    **
  71. ** History:                                **
  72. **    1.00 (16.10.96) - hardly released at all, just a personnal tool **
  73. **              for my everyday Amiga use :-)            **
  74. **    1.01 (16.12.97) - well, 14 months later! Isn't that sustained    **
  75. **              development ? :-) I just fixed a small bug    **
  76. **              and added some documentation.            **
  77. **              It might be about time for the first aminet    **
  78. **              release...                    **
  79. **                                    **
  80. ** THIS PROGRAM IS FREEWARE, MEANING THAT IT IS OFFERED TO YOU AS A    **
  81. ** GIFT, YOU DO NOT HAVE TO PAY ANYTHING FOR IT, EXCEPT FOR MINIMAL    **
  82. ** COPY & SHIPPING FEES. YOU MAY DISTRIBUTE COPIES OF IT TO ANYONE YOU    **
  83. ** WANT, BUT YOU MUST DISTRIBUTE THE ENTIRE AND UNMODIFIED ARCHIVE.    **
  84. ** COMMERCIAL USAGE IS FORBIDDEN WITHOUT MY WRITTEN PERMISSION.        **
  85. ** MOREOVER, I WILL NOT BE HELD RESPONSIBLE FOR ANY DAMAGE THE USE    **
  86. ** OF THIS PROGRAM MAY CAUSE. ALL USE IS AT YOUR OWN RISK. BY USING    **
  87. ** THIS PROGRAM AND RELATED FILES, YOU AGREE WITH THIS DISCLAIMER.    **
  88. **                                    **
  89. **    Feel free to contact me:                    **
  90. **    - Snail-Mail (new address!):                    **
  91. **        Frédéric Delacroix                    **
  92. **        4, rue Mirland                        **
  93. **        59300 VALENCIENNES                    **
  94. **        FRANCE                            **
  95. **    - Fidonet:                            **
  96. **        sorry, not available for now                **
  97. **    _ Francomédia:                            **
  98. **        101:176/114.8                        **
  99. **    - Internet (not very reliable):                    **
  100. **        frederic.delacroix@p8.f20.n322.z2.fidonet.org        **
  101. **                                    **
  102. *************************************************************************/
  103.  
  104. IF ~SHOW('Libraries','rexxxpk.library') THEN
  105.     IF ~ADDLIB('rexxxpk.library',0,-30,1) THEN EXIT 20
  106. IF ~SHOW('Libraries','rexxreqtools.library') THEN
  107.     IF ~ADDLIB('rexxreqtools.library',0,-30,1) THEN EXIT 20
  108. IF ~SHOW('Libraries','rexxsupport.library') THEN
  109.     IF ~ADDLIB('rexxsupport.library',0,-30,1) THEN EXIT 20
  110.  
  111. OPTIONS RESULTS
  112. PARSE ARG action arguments
  113. UPPER action
  114.  
  115. SELECT
  116.     WHEN    action=="GUI" THEN XPKGui(arguments)
  117.     WHEN    action=="OPEN" THEN XPKOpen(arguments)
  118.     WHEN    action=="INCLUDE" THEN XPKInclude(arguments)
  119.     WHEN    action=="SAVE" THEN XPKSave(arguments)
  120.     WHEN    action=="SAVEAS" THEN XPKSaveAs(arguments)
  121.     WHEN    action=="SAVEQUIT" THEN XPKSaveQuit(arguments)
  122.     WHEN    action=="STATUS" THEN XPKStatus(arguments)
  123.     OTHERWISE    rtezrequest("Unknown action.",,"XPKCed: Problem.",eztags)
  124. END
  125.  
  126. EXIT
  127.  
  128. /**** XPKGui ****/
  129.  
  130. XPKGui: PROCEDURE
  131.  
  132. CALL GetRexxTags
  133. msg='0A'X || '0A'X || "Please select operation:"
  134. o=rtezrequest(XPKStatMsg() || msg,"_Open...|_Include...|_Save|Save _as...|Save and _Quit|_Cancel","XPKCed: GUI mode",eztags,)
  135. SELECT
  136.     WHEN o=1 THEN XPKOpen(ARG(1))
  137.     WHEN o=2 THEN XPKInclude(ARG(1))
  138.     WHEN o=3 THEN XPKSave(ARG(1))
  139.     WHEN o=4 THEN XPKSaveAs(ARG(1))
  140.     WHEN o=5 THEN XPKSaveQuit(ARG(1))
  141.     OTHERWISE NOP
  142. END
  143. RETURN 0
  144.  
  145. /**** XPKOpen ****/
  146.  
  147. XPKOpen: PROCEDURE
  148.  
  149. PARSE ARG password .
  150. CALL GetRexxTags
  151. IF AskLose() THEN RETURN 0
  152. status dirname
  153. dirname=RESULT
  154. status restname
  155. filename=RESULT
  156. filename=rtfilerequest(dirname,filename,"XPK Open","_Open",multiselecttags,files)
  157. IF filename="" THEN RETURN 0
  158. IF DecompressFile(files.1) THEN RETURN 0
  159. "Open" losefile '22'X || files.1 || '22'X
  160. IF files.count>1 THEN DO i=2 TO files.count
  161.     IF DecompressFile(files.i) THEN RETURN 0
  162.     "Open new"
  163.     "Open" '22'X || files.i || '22'X
  164. END
  165. RETURN 0
  166.  
  167.  
  168. /**** XPKInclude ****/
  169.  
  170. XPKInclude: PROCEDURE
  171.  
  172. PARSE ARG password .
  173. CALL GetRexxTags
  174. filename=rtfilerequest(,,"XPK Include","_Include",fileselecttags,)
  175. IF (filename="") | (~rtresult) THEN RETURN 0
  176. IF DecompressFile(filename) THEN RETURN 0
  177. "Include file" '22'X || filename || '22'X
  178. RETURN 0
  179.  
  180.  
  181. /**** XPKSave ****/
  182.  
  183. XPKSave: PROCEDURE
  184.  
  185. PARSE ARG packer password .
  186. CALL GetRexxTags
  187. status filename
  188. fname=RESULT
  189. fstate=STATEF(fname)
  190. defpacker=packer
  191. IF defpacker="" THEN PARSE UPPER VAR fstate . . . . . . . defpacker . .
  192. "Save"
  193. IF ~RESULT THEN RETURN 0
  194. status filename
  195. fname=RESULT
  196. IF CompressFile(fname) THEN RETURN 0
  197. RETURN 0
  198.  
  199.  
  200. /**** XPKSaveAs ****/
  201.  
  202. XPKSaveAs: PROCEDURE
  203.  
  204. PARSE ARG packer password .
  205. CALL GetRexxTags
  206. status filename
  207. fname=RESULT
  208. fstate=STATEF(fname)
  209. defpacker=packer
  210. IF defpacker="" THEN PARSE UPPER VAR fstate . . . . . . . defpacker . .
  211. "Save as"
  212. IF ~RESULT THEN RETURN 0
  213. status filename
  214. fname=RESULT
  215. IF CompressFile(fname) THEN RETURN 0
  216. RETURN 0
  217.  
  218.  
  219. /**** XPKSaveQuit ****/
  220.  
  221. XPKSaveQuit: PROCEDURE
  222.  
  223. PARSE ARG packer password .
  224. CALL GetRexxTags
  225. status filename
  226. fname=RESULT
  227. fstate=STATEF(fname)
  228. defpacker=packer
  229. IF defpacker="" THEN PARSE UPPER VAR fstate . . . . . . . defpacker . .
  230. "Save"
  231. IF ~RESULT THEN RETURN 0
  232. status filename
  233. fname=RESULT
  234. IF CompressFile(fname) THEN RETURN 0
  235. OPTIONS FAILAT 11    /* to counter Ced's strange behavior with last quit */
  236. "Quit"
  237. RETURN 0
  238.  
  239.  
  240. /**** XPKStatus ****/
  241.  
  242. XPKStatus: PROCEDURE
  243.  
  244. CALL GetRexxTags
  245. rtezrequest(XPKStatMsg(),,"XPKCed: status",eztags,)
  246. RETURN 0
  247.  
  248.  
  249. /**** Other functions ****/
  250.  
  251. /* XPKStatMsg: returns the status message to display in requesters
  252. of STATUS and GUI */
  253.  
  254. XPKStatMsg: PROCEDURE
  255.  
  256. xpkclip=GetClip(XPKCed)
  257. IF xpkclip="" THEN xpkclip="0 ????